<template>
  <div class="container">
    <el-row type="flex" justify="space-between">
      <!-- 订单表单 -->
      <div class="main">
        <OrderForm v-if="ticketInfo.insurances" :ticketdata="ticketInfo" @setAllPrice="setAllPrice"></OrderForm>
      </div>

      <!-- 侧边栏 -->
      <div class="aside">
        <OrderAside v-if="ticketInfo" :data="ticketInfo" :allPrice="allPrice"></OrderAside>
      </div>
    </el-row>
  </div>
</template>

<script>
import OrderForm from "@/components/air/OrderForm.vue";
import OrderAside from "@/components/air/OrderAside.vue";
export default {
  components: {
    OrderForm,
    OrderAside
  },
  data() {
    return {
      ticketInfo: {
        insurances: [], //保险数据
        seat_infos: {}
      },
      allPrice: 0
    };
  },
  mounted() {
    this.getTicketInfo();
  },
  methods: {
    setAllPrice(price) {
      //  将传过来的总金额存到本地的data中
      this.allPrice = price;
    },
    getTicketInfo() {
      const { query } = this.$route;
      this.$axios({
        url: "/airs/" + query.id,
        method: "get",
        params: {
          seat_xid: query.seat_xid
        }
      }).then(res => {
        console.log("机票的数据", res);
        this.ticketInfo = res.data;
      });
    }
  }
};
</script>

<style lang="less" scoped>
.container {
  width: 1000px;
  margin: 20px auto;
}

/*aside*/
.aside {
  width: 350px;
  height: fit-content;
  border: 1px #ddd solid;
}
</style>